package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.dto.OrderDto;
import com.itheima.reggie.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Classname OrderController
 * @Description TODO
 * @Date 2023/3/11 20:52
 * @Created by 11404
 */

@Api(tags = "订单管理")
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    // 后台订单信息查询         // 尝试用DTO接收数据，报错缺少请求正文，解决是Get请求传参不能用JOSN对象接
    @ApiOperation(value = "后台订单信息查询")
    @Cacheable(value = "order",key = "#orderDto.number")
    @GetMapping("/page")
    public ResultInfo selectOrder(Integer page, Integer pageSize,OrderDto orderDto){

        Page<Order> orderList = orderService.selectOr(page, pageSize,orderDto.getNumber(),orderDto.getEndTime(),orderDto.getBeginTime());

        return ResultInfo.success(orderList);
    }


}
